<div class="advancedSearchFormContainer">
	<form action="<?= URL::site('advanced') ?>" method="get" id="advancedTourSearch">
		<div class="advancedSearchForm">
			<div class="top">
				<div class="left">
					Расширенный подбор тура
				</div>
				<div class="right">
					<a href="<?= URL::site() ?>">Вернуться на главную</a>
				</div>
			</div>
			<div class="shadow"></div>
			<div class="form">
				<div class="selectButton searchSelectButton" id="from">
					<div class="buttonTitle">
						<?= $fromName ?>
					</div>
				</div>
				<div class="selectButton searchSelectButton" id="where">
					<div class="buttonTitle"><?= $params['where']['name'] ?></div>
				</div>
				<div class="selectButton searchSelectButton" id="aviacompany" country_id="<?= $params['fromCountry']['value'] ?>" city_id="<?= $params['fromCity']['value'] ?>">
					<div class="buttonTitle"><?= $params['aviacompany']['name'] ?></div>
				</div>
				<div class="selectButton searchSelectButton" id="when">
					<div class="buttonTitle"><?= $params['when']['name'] ?></div>
				</div>
				<div class="selectButton searchSelectButton" id="nights">
					<div class="buttonTitle"><?= $params['nights']['name'] ?></div>
				</div>
			</div>
			<div class="dotted"></div>
			<div class="form" style="padding-top: 20px">
				<div class="selectButton searchSelectButton" id="package">
					<div class="buttonTitle"><?= $params['package']['name'] ?></div>
				</div>
				<div class="selectButton searchSelectButton" id="hotel">
					<div class="buttonTitle"><?= $params['hotel']['name'] ?></div>
				</div>
				<div class="selectButton searchSelectButton" id="roomType">
					<div class="buttonTitle"><?= $params['roomType']['name'] ?></div>
				</div>
				<div class="selectButton searchSelectButton" id="pitanie">
					<div class="buttonTitle"><?=  $params['pitanie']['name'] ?></div>
				</div>
				<div class="selectButton searchSelectButton" id="childrens" onclick="loadAjaxForm(this, 'childrens')">
					<div class="buttonTitle"><? $col = $params['adults']['value'] + $params['childrens']['value']; if ($col != 0) { echo $col.' человек'; } else { echo 'Количество человек'; } ?></div>
				</div>
			</div>
			<div class="dotted"></div>

			<!-- поля формы тут: -->
			<input type="hidden" name="fromCountry" value="<?= $params['fromCountry']['name'].'!'.$params['fromCountry']['value'] ?>" />
			<input type="hidden" name="fromCity" value="<?= $params['fromCity']['name'].'!'.$params['fromCity']['value'] ?>" />
			<input type="hidden" name="where" value="<?= $params['where']['name'].'!'.$params['where']['value'] ?>" />
			<input type="hidden" name="aviacompany" value="<?= $params['aviacompany']['name'].'!'.$params['aviacompany']['value'] ?>" />
			<input type="hidden" name="when" value="<?= $params['when']['value'] ?>" />
			<input type="hidden" name="nights" value="<?= $params['nights']['name'].'!'.$params['nights']['value'] ?>" />
			<input type="hidden" name="package" value="<?= $params['package']['name'].'!'.$params['package']['value'] ?>" />
			<input type="hidden" name="hotel" value="<?= $params['hotel']['name'].'!'.$params['hotel']['value'] ?>" />
			<input type="hidden" name="stars" value="<?= $params['stars']['value'] ?>" />
			<input type="hidden" name="roomType" value="<?= $params['roomType']['name'].'!'.$params['roomType']['value'] ?>" />
			<input type="hidden" name="adults" value="<?= $params['adults']['value'] ?>" />
			<input type="hidden" name="childrens" value="<?= $params['childrens']['value'] ?>" />
			<input type="hidden" name="childrenAge_1" value="<?= $params['childrenAge_1']['value'] ?>" />
			<input type="hidden" name="childrenAge_2" value="<?= $params['childrenAge_2']['value'] ?>" />
			<input type="hidden" name="pitanie" value="<?= $params['pitanie']['name'].'!'.$params['pitanie']['value'] ?>" />
			<input type="hidden" name="additional" value="<?= $params['additional']['name'].'!'.$params['additional']['value'] ?>" />
			<input type="hidden" name="currency" value="<?= $params['currency']['value'] ?>" />

			<div class="extraForm">
				<table cellpadding="0" cellspacing="0" width="100%">
					<tr>
						<td width="33%">
							Дополнительные услуги<br />
							<span class="additional" id="additional">Выбрать</span>
						</td>
						<td width="34%">
							Цены показывать в <? if ($params['currency']['name'] == 'USD'): ?><strong style="display: none">тенге</strong><strong>USD</strong><? else: ?><strong>тенге</strong><strong style="display: none">USD</strong><? endif ?><br />
							<span>Изменить</span>
						</td>
						<td width="33%">
							Цена<br />
							от <input type="text" name="priceFrom" class="subscribeInput" value="<?= $params['priceFrom']['value'] ?>" /> до <input type="text" name="priceTo" class="subscribeInput" value="<?= $params['priceTo']['value'] ?>" />
						</td>
					</tr>
				</table>
			</div>
			<div class="dotted"></div>
			<div class="total">
				<span>Итог:</span>
				<div>
					Вылет из <span class="totalSpan" <?= $params['fromCountry']['display'] ?>><strong class="total_fromCountry"><?= $params['fromCountry']['name'] ?></strong></span>
					<span class="totalSpan" <?= $params['fromCity']['display'] ?>>, <strong class="total_fromCity"><?= $params['fromCity']['name'] ?></strong></span>
					<span class="totalSpan" <?= $params['where']['display'] ?>>, прилёт в <strong class="total_where"><?= $params['where']['name'] ?></strong></span>
					<span class="totalSpan" <?= $params['aviacompany']['display'] ?>>, авиакомпанией: <strong class="total_aviacompany"><?= $params['aviacompany']['name'] ?></strong></span>
					<span class="totalSpan" <?= $params['when']['display'] ?>>, <strong class="total_when"><?= $params['when']['name'] ?></strong></span>
					<span class="totalSpan" <?= $params['nights']['display'] ?>>, на <strong class="total_nights"><?= $params['nights']['name'] ?></strong></span>
					<span class="totalSpan" <?= $params['package']['display'] ?>>, тур пакеты: <strong class="total_package"><?= $params['package']['name'] ?></strong></span>
					<span class="totalSpan" <?= $params['hotel']['display'] ?>>, отель: <strong class="total_hotel"><?= $params['hotel']['name'] ?></strong></span>
					<span class="totalSpan" <?= $params['roomType']['display'] ?>>, тип отеля: <strong class="total_roomType"><?= $params['roomType']['name'] ?></strong></span>
					<span class="totalSpan" <?= $params['adults']['display'] ?>>, <strong class="total_adults"><?= $params['adults']['name'] ?></strong></span>
					<span class="totalSpan" <?= $params['childrens']['display'] ?>>, <strong class="total_childrens"><?= $params['childrens']['name'] ?></strong></span>
					, цены в <strong class="total_currency"><?= (!empty($params['currency']['name'])) ? $params['currency']['name'] : 'тенге' ?></strong>
					<!-- <span class="totalSpan totalNull">Выберите страну и город из которого вылетаете</span> -->
				</div>
			</div>
		</div>
		<div class="bot">
			<div class="left">
				<input type="checkbox" name="dailyRoom" <?= (!empty($_GET['dailyRoom'])) ? 'checked="checked"' : '' ?> /><div>Суточные номера</div>
			</div>
			<input type="submit" value="Показать туры" class="blueButton" style="float: right; margin: 7px 20px 0 0" />
		</div>
	</form>
	<? if ($search != false): ?>
	<div class="bigArrow"></div>
	<!-- Результаты поиска: -->
	<div class="advancedSearchResults">
		<div class="top">
			<div class="left sortBy">
				Сортировать: <span class="active">по цене</span> <span>по популярности</span>
			</div>
			<!-- <div class="right">
				<a href="<?= URL::site() ?>">Вернуться на главную</a>
			</div> -->
		</div>
		<table cellpadding="0" cellspacing="1">
			<tr>
				<th>
					Дата заезда
				</th>
				<th>
					Ночей
				</th>
				<th>
					Отель
				</th>
				<th>
					Тур пакет
				</th>
				<th>
					Питание
				</th>
				<th>
					Размещение
				</th>
				<th>
					Стоимость
				</th>
				<th>
					Авиа перевозчик
				</th>
				<th>
					Оформление заказа
				</th>
			</tr>
			<? if (isset($search)): ?>
			<? foreach($search as $data): ?>
			<tr style="background: #eeeeee">
				<td>
					<div class="fulldate">
						<?= $params['when']['name'] ?>
					</div>
					<div class="weekday">
						Пн
					</div>
					<div class="time">
						Вылет: <?= $data['flight_out_time'] ?>
					</div>
				</td>
				<td>
					<div class="fulldate">
						<?= $params['nights']['name'] ?>
					</div>
					<div class="weekday">
						до:
					</div>
					<div class="weekday">
						<?= $data['back_date'] ?>
					</div>
				</td>
				<td>
					<div>
						<a href="#"><?= $data['hotel_title'] ?></a>
					</div>
					<div class="weekday">
						<?= $data['room_type'] ?>
					</div>
				</td>
				<td>
					<div>
						<a href="#"><?= $data['package_title'] ?></a>
					</div>
					<div class="weekday">
						<?= $data['package_description'] ?>
					</div>
				</td>
				<td>
					<div class="fulldate">
						<?= $data['food'] ?>
					</div>
				</td>
				<td>
					<div class="fulldate">
						<?= $data['adult_count'] ?> взрослых <?= $data['child_count'] ?> ребёнок
					</div>
				</td>
				<td>
					<div class="fulldate">
						<?= round($data['sum'],2) ?> USD
					</div>
				</td>
				<td>
					<div class="fulldate">
						<?= $data['aviacompany_out'] ?><br />
						<?= $data['aviacompany_back'] ?>
					</div>
				</td>
				<td>
					<form action="<?= URL::base() ?>order?tour_id=1" method="post">
						<input type="submit" class="blueButton" value="Заказать" />
					</form>
				</td>
			</tr>
			<? endforeach ?>
			<? else: ?>
			<tr><td colspan="9" align="center">Не найдено</td></tr>
			<? endif?>
		</table>
	</div>

	<div class="bot">
		<div class="left paging">
			<?= $pagination ?>
		</div>
		<div class="right" style="float: right; margin-right: 20px; line-height: 40px">
			<img style="margin-top: 12px" src="<?= URL::site('static/css/advanced/excel.png') ?>" alt="">
			<a href="#">Скачать в виде прайса Excel</a>
		</div>
	</div>
	<div class="botShadow">
		<div class="left"></div>
		<div class="right"></div>
	</div>
	<? endif ?>
</div>